package org.zxt.web.buss.api;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import static org.zxt.web.context.ResourceType.*;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.zxt.web.buss.domain.Buss;
import org.zxt.web.buss.service.BussService;
import org.zxt.web.context.annotation.*;
import org.zxt.web.context.mybatis.plugin.pagehelper.PageHelper;
import org.zxt.web.nio.Method;

import javax.annotation.Resource;
import java.io.IOException;

@Resource(type = Action.class)
@RequestMapping("/buss")
public class BussController {
    @Resource
    private BussService bussService;

    @RequestMapping(value = "/:path/:test")
    public Object path(@PathVariable("path") String path,@PathVariable("test") String test){
        return JSONObject.toJSON(bussService.list());
    }
    @RequestMapping(method = Method.POST)
    public String path(@RequestBody JSONArray body, @RequestHeader("content-length") Integer total) throws IOException {
        return null;
    }
    @RequestMapping(value = "/xxx1",method = Method.POST)
    public IPage<Buss> pathxxx(IPage<Buss> page, @RequestBody JSONArray body, @RequestHeader("content-length") Integer total) throws IOException {
        return PageHelper.doPageAndSort(page, ()->bussService.list());
    }
    @RequestMapping(value = "/page")
    public Object path1(IPage<Buss> page, Buss buss){
        return JSONObject.toJSON(bussService.doPage(page, buss));
    }
}
